"use strict";
const e = require("../common/vendor.js");

function a() {
  const {
    user_Token: a
  } = e.wx$1.getStorageSync("userInfor");
  return "Basic " + e.gBase64.encode(a + ":")
}

function o(a) {
  e.wx$1.showToast({
    title: a,
    icon: "none",
    duration: 1e3
  })
}
exports.requestApi = function (i, n = {}, r = "GET") {
  return new Promise(((s, t) => {
    e.index.request({
      url: "http://192.168.23.1:8900/api" + i,
      method: r,
      data: n,
      header: {
        Authorization: a()
      },
      success: a => {
        switch (a.statusCode) {
          case 200:
            s(a.data), e.wx$1.hideLoading();
            break;
          case 404:
            console.error("接口不存在"), t("404"), e.wx$1.hideLoading();
            break;
          case 401:
            e.wx$1.navigateTo({
              url: "/pages/Login-pop-up/login"
            }), console.error("没有权限"), t("401"), e.wx$1.hideLoading();
            break;
          case 500:
            o("发生异常错误"), t("500"), e.wx$1.hideLoading();
            break;
          case 501:
            o("发生异常错误"), t("501"), e.wx$1.hideLoading();
            break;
          case 502:
            o("发生异常错误"), t("502"), e.wx$1.hideLoading();
            break;
          case 400:
            console.error(a.data.msg), t("400"), e.wx$1.hideLoading();
            break;
          case 422:
            o(a.data.msg), t("422"), e.wx$1.hideLoading()
        }
      },
      fail: a => {
        t(a), e.wx$1.hideLoading()
      }
    })
  }))
};